using System;
using System.Data;
using System.Data.SqlClient;
using SystemFrameworks;
using Common;
using DataAccess;
using Microsoft.ApplicationBlocks.Data;

namespace BusinessRules
{
    public class SigImagenesPrograma
    {
        private const String SIP_ID_PARAM = "@SIP_ID";
        private const String SPZ_ID_PARAM = "@SPZ_ID";
        


        private string _CadenaConexion;

        public string CadenaConexion
        {
            get { return _CadenaConexion; }
            set { _CadenaConexion = value; }
        }
        public SigImagenesPrograma(string strCadenaConecxion)
        {
            CadenaConexion = strCadenaConecxion;
        }

        public SigImagenesProgramasData ConsultarSigImagenesProgramaSPZid(String strSpzId)
        {
            SqlParameter param1 = new SqlParameter(SPZ_ID_PARAM, strSpzId);
            
            SqlParameter[] parameters = { param1};
            SigImagenesProgramasData objSigImagenesProgramasData = new SigImagenesProgramasData();
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_IMAGENES_PROGRAMAS_SPZ_ID", objSigImagenesProgramasData, parameters);
            return objSigImagenesProgramasData;
        }

        public SigImagenesProgramasData ConsultarSigImagenesProgramaSIPid(String strSipId)
        {
            SqlParameter param1 = new SqlParameter(SIP_ID_PARAM, strSipId);

            SqlParameter[] parameters = { param1 };
            SigImagenesProgramasData objSigImagenesProgramasData = new SigImagenesProgramasData();
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_IMAGENES_PROGRAMAS_SIP_ID", objSigImagenesProgramasData, parameters);
            return objSigImagenesProgramasData;
        }

        public void EliminarSigImagenes(string parSPZ_ID, params SqlTransaction[] objTransaction)
        {
            try
            {

                SqlParameter param1 = new SqlParameter(SPZ_ID_PARAM, parSPZ_ID);
                SqlParameter[] parameters = { param1 };
                if (objTransaction.Length == 0)
                {
                    SqlHelper.ExecuteNonQuery(CadenaConexion, CommandType.StoredProcedure, "PAS_ELIMINAR_SIG_IMAGENES_PROGRAMAS_SPZ_ID", parameters);
                }
                else
                {
                    SqlHelper.ExecuteNonQuery(objTransaction[0], CommandType.StoredProcedure, "PAS_ELIMINAR_SIG_IMAGENES_PROGRAMAS_SPZ_ID", parameters);
                }

            }
            catch (SqlException sqlEx)
            {
                throw new ApplicationExceptionManager(Utilidad.DisplaySqlErrors(sqlEx, "PAS_ELIMINAR_SIG_IMAGENES_PROGRAMAS_SPZ_ID"), sqlEx);
            }
            catch (Exception ex)
            {
                throw new ApplicationExceptionManager(Utilidad.TraerMensaje("gmsgErrorInsertar", GetType().FullName), ex);
            }
        }

        //public SigAccionData ConsultarAccionAccID(String strAccId)
        //{
        //    SqlParameter param1 = new SqlParameter(ACC_ID_PARAM, strAccId);

        //    SqlParameter[] parameters = { param1 };
        //    SigAccionData objSigPlanAccionData = new SigAccionData();
        //    Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataTable(CadenaConexion, CommandType.StoredProcedure, "PAS_CONSULTAR_SIG_ACCION_ACC_ID", objSigPlanAccionData, parameters);
        //    return objSigPlanAccionData;
        //}
    }
}
